'use strict'
var arr =['item',1,2,3,4];
var arr1 =[1,2,3,4,5];
console.log(arr.indexOf('item'));
console.log(arr1.indexOf('item'));

var sum =0;
for(var i =0;i<arr1.length;i++){
    sum =sum + arr1[i];
}
console.log(sum);

function isupdate(arr,list){
    var a =[];
    for(var i = 0;i<arr.length;i++){
        if(list != arr[i]){
            a.push(arr[i]);
        }
    }
    return a;
}
console.log(isupdate(arr1,1));

function Add(arr,n){
    var a = [];
    for(var i=0;i<arr.length;i++){
     a.push(arr[i]);   
    }
    a.push(n);
    return a;
}
console.log(Add(arr1,10));

function DeleteEnd(arr){
    var a = [];
    for(var i=0;i<arr.length;i++){
        a.push(arr[i]);
    }
    a.splice(arr.length-1,1);
    return a;
}
console.log(DeleteEnd(arr1));

function Addtop(arr,item){
    var a = [];
    for(var i=0;i<arr.length;i++){
        a.push(arr[i]);
    }
    a.unshift(item);
    return a;
}
console.log(Addtop(arr1,10));

function Deletetop(arr){
    var a = [];
    for(var i=0;i<arr.length;i++){
        a.push(arr[i]);
    }
    a.shift();
    return a;
}
console.log(Deletetop(arr1));

function pj(arr1,arr2){
    var a =[];
    var res = a.concat(arr1,arr2);
    return res;
}
console.log(pj(arr,arr1));

function conadd(arr,index,item){
    var a = [];
    for(var i =0;i<arr.length;i++){
        a.push(arr[i]);
    }
    a.splice(index,0,item);
   return a;
}
console.log(conadd(arr1,2,3));

function arrsum(arr,item){
    var sum =0;
    for(var i =0;i<arr.length;i++){
        if(item ===arr[i]){
            sum = sum+1;
        }
    }
    return sum;
}
console.log(arrsum(arr1,2));

function isre(arr){
   var a =[];
    for(var i = 0;i<arr.length;i++){
        if(arr.indexOf(arr[i]) != -1 && arr.indexOf(arr[i]) != arr.lastIndexOf(arr[i])){
            a.push(arr[i]);
        }
    }
    return a;
}
console.log(isre(arr1));

function pf(arr){
    var a =[];
    for(var i = 0;i<arr.length;i++){
        a.push(arr[i]*arr[i]);
    }
    return a;
}
console.log(pf(arr1));

function allre(arr,item){
    var a = [];
    var rest =[];
    for(var i =0;i<arr.length;i++){
        a[0] = arr[i];
        var isre = a.indexOf(item);
        if(isre != -1){
        rest.push(i);
        }

    }
    return rest;
}

console.log(allre(arr1,1));

